﻿
<%@ page import="com.claims.Employee" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Edit Employee</title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${resource(dir:'')}"><g:message code="menu.home" /></a></span>
            <span class="menuButton"><g:link class="list" action="list">Employee List</g:link></span>
            <span class="menuButton"><g:link class="create" action="create">New Employee</g:link></span>
        </div>
        <div class="body">
            <h1>Edit Employee</h1>
						<jdsb:message />
            <g:hasErrors bean="${employeeInstance}">
            <div class="errors">
                <g:renderErrors bean="${employeeInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <input type="hidden" name="id" value="${employeeInstance?.id}" />
                <input type="hidden" name="version" value="${employeeInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="name">Name:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'name','errors')}">
                                    <input type="text" id="name" name="name" value="${fieldValue(bean:employeeInstance,field:'name')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="nric">Nric:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'nric','errors')}">
                                    <input type="text" id="nric" name="nric" value="${fieldValue(bean:employeeInstance,field:'nric')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="dateOfBirth">Date Of Birth:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'dateOfBirth','errors')}">
                                    <g:datePicker name="dateOfBirth" value="${employeeInstance?.dateOfBirth}" precision="minute" ></g:datePicker>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="address">Address:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'address','errors')}">
                                    <input type="text" id="address" name="address" value="${fieldValue(bean:employeeInstance,field:'address')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="address2">Address2:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'address2','errors')}">
                                    <input type="text" id="address2" name="address2" value="${fieldValue(bean:employeeInstance,field:'address2')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="city">City:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'city','errors')}">
                                    <input type="text" id="city" name="city" value="${fieldValue(bean:employeeInstance,field:'city')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="postcode">Postcode:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'postcode','errors')}">
                                    <input type="text" id="postcode" name="postcode" value="${fieldValue(bean:employeeInstance,field:'postcode')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="state">State:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'state','errors')}">
                                    <g:select optionKey="id" from="${com.claims.code.State.list()}" name="state.id" value="${employeeInstance?.state?.id}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="branch">Branch:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'branch','errors')}">
                                    <g:select optionKey="id" from="${com.claims.code.Branch.list()}" name="branch.id" value="${employeeInstance?.branch?.id}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="claims">Claims:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'claims','errors')}">
                                    
<ul>
<g:each var="c" in="${employeeInstance?.claims?}">
    <li><g:link controller="claim" action="show" id="${c.id}">${c?.encodeAsHTML()}</g:link></li>
</g:each>
</ul>
<g:link controller="claim" params="['employee.id':employeeInstance?.id]" action="create">Add Claim</g:link>

                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="department">Department:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'department','errors')}">
                                    <g:select optionKey="id" from="${com.claims.code.Department.list()}" name="department.id" value="${employeeInstance?.department?.id}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="dependants">Dependants:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'dependants','errors')}">
                                    
<ul>
<g:each var="d" in="${employeeInstance?.dependants?}">
    <li><g:link controller="dependant" action="show" id="${d.id}">${d?.encodeAsHTML()}</g:link></li>
</g:each>
</ul>
<g:link controller="dependant" params="['employee.id':employeeInstance?.id]" action="create">Add Dependant</g:link>

                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="employeeId">Employee Id:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'employeeId','errors')}">
                                    <input type="text" id="employeeId" name="employeeId" value="${fieldValue(bean:employeeInstance,field:'employeeId')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="level">Level:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'level','errors')}">
                                    <g:select optionKey="id" from="${com.claims.code.Level.list()}" name="level.id" value="${employeeInstance?.level?.id}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="user">User:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'user','errors')}">
                                    <g:select optionKey="id" from="${com.claims.User.list()}" name="user.id" value="${employeeInstance?.user?.id}" ></g:select>
                                </td>
                            </tr> 
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" value="Update" /></span>
                    <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
